package com.group.flagtivities;

import android.content.Context;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.ViewGroup.LayoutParams;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class ViewUtil {

	public static TextView generateDefaultTextView(Context context, String text) {
		TextView view = new TextView(context);
		view.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
		view.setSingleLine(true);
		view.setText(text);
		view.setTypeface(Typeface.createFromAsset(context.getAssets(), "fonts/Chunkfive.otf"), Typeface.NORMAL);
		view.setPadding(10, 10, 10, 10);
		view.setTextColor(context.getResources().getColor(R.color.white));
		view.setShadowLayer(1.0f, 0.0f, 0.0f, context.getResources().getColor(R.color.gray_dark));
		view.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.background_recent));
		view.setGravity(Gravity.CENTER_VERTICAL);
		view.setEllipsize(TextUtils.TruncateAt.END);
		view.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
		view.setPadding(view.getPaddingLeft(), view.getPaddingTop(), view.getPaddingRight() + 20, view.getPaddingBottom());
		
		return view;
	}
	
	public static ImageView generateDefaultImageView(Context context, Drawable drawable) {
		ImageView view = new ImageView(context);
		view.setLayoutParams(new RelativeLayout.LayoutParams(25, 25));
		view.setImageDrawable(drawable);
		view.setAdjustViewBounds(true);
		RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)view.getLayoutParams();
		params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
		params.addRule(RelativeLayout.CENTER_VERTICAL);
		view.setLayoutParams(params);
		
		return view;
	}
	
	public static RelativeLayout generateDefaultRelativeLayout(Context context, Drawable drawable) {
		RelativeLayout view = new RelativeLayout(context);
		view.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT));
		view.setBackgroundDrawable(drawable);
		view.setPadding(0, 0, 10, 0);
		
		return view;
	}
	
}
